package wwk.common.http;

import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;

import wwk.common.constant.Commonstant;

public class HttpResponseData
{
	public HttpURLConnection httpURLConnection;
	
	public boolean responseFinished;
	
	public int errorCode;
	public String errorDesc;
	
	public byte[] bytes;
	public int contentLength;
	
	public String encoding;
	
	public boolean cryptographic;
	
	public int tag;
	
	public boolean isSuccess()
	{
		return errorCode==200;
	}
	
	public int getBytesSize()
	{
		return bytes==null?0:bytes.length;
	}
	
	public String getString()
	{
		String string=null;
		
		if(bytes!=null)
		{
			try 
			{
				string = new String(bytes, 0, getBytesSize(),encoding!=null?encoding:Commonstant.ENCODING_UTF8);
			} 
			catch (UnsupportedEncodingException e) 
			{
				e.printStackTrace();
			}
		}
		
		return string;
	}
}